
package org.yn.gift.exception;

/**
 * 用来定义所有的响应码
 * @author Huhu
 */
public enum ResponseCode {

    RESPONSE_CODE_200(200,"操作成功!"),
    RESPONSE_CODE_400(400,"参数类型异常!"),
    RESPONSE_CODE_40010(40010,"参数非空异常!"),
    RESPONSE_CODE_40011(40011,"密码不一致,请检查后重新输入!"),
    RESPONSE_CODE_40012(40012,"该店铺名称已存在,请重新输入!"),
    RESPONSE_CODE_40013(40013,"老铁，你不选中数据，臣妾上架不了啊...."),
    RESPONSE_CODE_40014(40014,"老铁，你不选中数据，臣妾下架不了啊...."),
    RESPONSE_CODE_40015(40015,"老铁,你选择的数据都不满足上架的条件!"),
    RESPONSE_CODE_40016(40016,"图片验证码输入错误,请检查后重新提交!"),
    RESPONSE_CODE_40017(40017,"图片验证码已过期,请重新获取!"),
    RESPONSE_CODE_40018(40018,"该手机号已注册,请直接登录!"),
    RESPONSE_CODE_40019(40019,"请不要频繁发送手机验证码!"),
    RESPONSE_CODE_40020(40020,"手机验证码已过期,请重新获取!"),
    RESPONSE_CODE_40021(40021,"手机验证码输入错误,请重新输入!"),
    RESPONSE_CODE_40022(40022,"用户名或邮箱已存在,请重新输入!"),
    RESPONSE_CODE_40023(40023,"账号或密码错误,请重新输入!"),
    RESPONSE_CODE_40024(40024,"手机号不能为空!"),
    RESPONSE_CODE_40025(40025,"该手机号已绑定微信用户,请直接登录!"),
    RESPONSE_CODE_403(403,"没有操作权限!"),
    RESPONSE_CODE_500(500,"网络异常,请刷新重试!"),
    ;

    private Integer code;
    private String message;

    ResponseCode() {
    }

    ResponseCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ResponseCode getResponseCodeByCode(Integer code) {
        ResponseCode[] values = ResponseCode.values();
        ResponseCode result = ResponseCode.RESPONSE_CODE_500;
        for (ResponseCode value : values) {
            if(value.getCode().equals(code)){
                result = value;
                break;
            }
        }
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}